home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Indispensables / Movie Collection / MovieCollection5403.exe / {app} / php5 / sql.class.php < prev    next >
PHP Script  |  2005-03-07  |  2KB  |  94 lines

  1. <?php
  2.  
  3. require_once('params.class.php');
  4.  
  5. class TmcSql
  6. {
  7.    private $db = null;
  8.    private $showTrace = FALSE;
  9.  
  10.    function __construct($AshowTrace=FALSE, $Aupdating=FALSE)
  11.    {
  12.       if (!$Aupdating)
  13.       {
  14.          if (file_exists('empty.inc'))
  15.          {
  16.             echo("<html>");
  17.                echo("<body>");
  18.                   echo("<b>La base de donnΘe doit Ωtre mise α jour</b><br />");
  19.                echo("</body>");
  20.             echo("</html>");
  21.    
  22.             die('');
  23.          }
  24.       }
  25.  
  26.       $this->showTrace = $AshowTrace;
  27.  
  28.       $sqliteerror = null;
  29.       if (!($this->db = @sqlite_open($_SESSION["mc_params"]->getBdd(), 0666, $sqliteerror)))
  30.       {
  31.          die ($sqliteerror);
  32.       }
  33.    }
  34.  
  35.    function __destruct()
  36.    {
  37.       if (isset($this->db))
  38.          sqlite_close($this->db);
  39.    }
  40.  
  41.    function execSql($Astmt)
  42.    {
  43.       if ($this->showTrace)
  44.          echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
  45.       $result=@sqlite_query($this->db, $Astmt);
  46.       $id_error=sqlite_last_error($this->db);
  47.       if ($id_error)
  48.          die("<b>".sqlite_error_string($id_error)."</b><br />");
  49.       else
  50.       {
  51.          if ($this->showTrace)
  52.             echo("<b>".sqlite_changes($this->db)." enregistrements modifΘ(s).</b><br />");
  53.       }
  54.    }
  55.  
  56.    function execSql_no_exception($Astmt)
  57.    {
  58.       if ($this->showTrace)
  59.          echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
  60.       $result=@sqlite_query($this->db, $Astmt);
  61.       $id_error=sqlite_last_error($this->db);
  62.       if ($id_error)
  63.       {
  64.          if ($this->showTrace)
  65.             echo("<b>".sqlite_error_string($id_error)."</b><br />");
  66.       }
  67.       else
  68.       {
  69.          if ($this->showTrace)
  70.             echo("<b>".sqlite_changes($this->db)." enregistrements modifΘ(s).</b><br />");
  71.       }
  72.    }
  73.  
  74.    function openSql($Astmt)
  75.    {
  76.       if ($this->showTrace)
  77.          echo("<b>RequΩte: </b> ".nl2br($Astmt)."<br />");
  78.       $result=@sqlite_query($this->db, $Astmt);
  79.       $id_error=sqlite_last_error($this->db);
  80.       if ($id_error)
  81.          die("<b>".sqlite_error_string($id_error)."</b><br />");
  82.  
  83.       $rows = array();
  84.       while ($r = sqlite_fetch_array($result))
  85.       {
  86.          $rows[] = $r;
  87.       }
  88.       return $rows;
  89.  
  90.    }
  91.  
  92. }
  93.  
  94. ?>